package com.juc.future;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author Zan
 * @Create 2024/5/6 19:39
 * @ClassName : CompletableFutureDemo
 * @Description : TODO 请用一句话描述该类的功能
 */
public class CompletableFutureDemo {
    public static void main(String[] args) throws Exception {
//        new Thread(new MyThread1(), "a1");

//        new Thread(new MyThread2(), "a2"); // error

        FutureTask<String> futureTask = new FutureTask<>(new MyThread2());

        Thread a3 = new Thread(futureTask, "a3");
        a3.start();

        System.out.println(futureTask.get());

    }
}

class MyThread1 implements Runnable {
    @Override
    public void run() {

    }
}

class MyThread2 implements Callable<String> {
    @Override
    public String call() throws Exception {
        System.out.println("----------com in call()");
        return "hello";
    }
}
